package startup

import (
	"fmt"
	"gitee.com/yimtune/webook/internal/repository"
	"gitee.com/yimtune/webook/internal/repository/dao"
	"gitee.com/yimtune/webook/internal/service/sms"
	"gitee.com/yimtune/webook/internal/service/sms/async"
)

func InitAsyncSmsService(svc sms.Service) *async.Service {
	db := InitDB()
	err := db.AutoMigrate(&dao.AsyncSms{})
	fmt.Println("自动建表错误：", err)
	asyncSmsDAO := dao.NewGORMAsyncSmsDAO(db)
	asyncSmsRepository := repository.NewAsyncSMSRepository(asyncSmsDAO)
	loggerV1 := InitLogger()
	asyncService := async.NewService(svc, asyncSmsRepository, loggerV1)
	return asyncService
}
